package com.study.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.study.common.domin.User;
import com.study.mapper.UserMapper;
import com.study.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: TODO
 * @Author: csc
 * @Date: 2024/8/16 10:37
 * @Version: 1.0
 **/
@Service
@DS("slave")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    @DS("master") // 增加、修改、删除方法走主库
    public boolean saveOrUpdate(User user) {
        return super.saveOrUpdate(user);
    }

    @Override
    @DS("slave") // 查询方法走从库
    public List<User> list() {
        return super.list();
    }

}
